package cn.south.campus.business.service.impl;

import cn.south.campus.business.mapper.WithdrawalAuditMapper;
import cn.south.campus.business.model.bo.LoginContext;
import cn.south.campus.business.model.bo.LoginInfo;
import cn.south.campus.business.model.entity.WithdrawalAudit;
import cn.south.campus.business.model.enums.WalletEnums;
import cn.south.campus.business.service.WithdrawalAuditService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * <p>
 * 提现审核表 服务实现类
 * </p>
 *
 * @author chow
 * @since 2024-11-14
 */
@Service
@AllArgsConstructor
public class WithdrawalAuditServiceImpl extends ServiceImpl<WithdrawalAuditMapper, WithdrawalAudit> implements WithdrawalAuditService {

    private final WithdrawalAuditMapper withdrawalAuditMapper;

    @Override
    public void insertAudit(BigDecimal amount, String bizNo) {
        LoginInfo context = LoginContext.getContext();
        WithdrawalAudit withdrawalAudit = new WithdrawalAudit();
        withdrawalAudit.setUserId(context.getId());
        withdrawalAudit.setBizNo(bizNo);
        withdrawalAudit.setAmount(amount);
        withdrawalAudit.setStatus(WalletEnums.WithdrawalAuditEnums.PENDING.getCode());
        withdrawalAuditMapper.insert(withdrawalAudit);
    }
}
